﻿using DataAccess;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogic
{
    public class PositionBL:MarshalByRefObject
    {
        private PositionDA positionDA;
        public override object InitializeLifetimeService()
        {
            return null;// live forever;
        }
        public PositionBL()
        {
            positionDA = new PositionDA();
        }
        public int addPosition(string name)
        {
            bool isEx = positionDA.isPositionExist(name);
            if (isEx)
                return -1;
            return positionDA.addPosition(name);
        }

        public bool updatePosition(int id, string name)
        {
            bool isEx = positionDA.isPositionExist(name);
            if (isEx)
                return false;
            return positionDA.updatePosition(id, name);
        }

        public Position getPositionById(int id)
        {
            return positionDA.getPositionById(id);

        }

        public Position[] getAllPosition()
        {
            return positionDA.getAllPosition();

        }
    }
}
